﻿
@{
    ViewData["Title"] = "Info";
    Layout = "~/Views/Shared/_Back.cshtml";
    IVBlog.Models.Info info = ViewBag.info as IVBlog.Models.Info;
}

<!--编号、我的网名、座右铭、QQ、邮箱、QQ群-->
<div class="layui-card">
    <div class="layui-card-header">
        <h2>我的信息</h2>
    </div>
    <div class="layui-card-body" id="read">
        <table class="layui-table">
            <tbody>
                <tr>
                    <th>编号</th>
                    <td>@info.InfoId</td>
                </tr>
                <tr>
                    <th>我的网名</th>
                    <td>@info.InfoName</td>
                </tr>
                <tr>
                    <th>我的座右铭</th>
                    <td>@info.Motto</td>
                </tr>
                <tr>
                    <th>我的邮箱</th>
                    <td>@info.Email</td>
                </tr>
                <tr>
                    <th>我的QQ群</th>
                    <td>@info.Qqgroup</td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="layui-card-body " id="edit" style="display:none">
        <table class="layui-table">
            <tbody>
                <tr>
                    <th>编号</th>
                    <td>
                        <input type="text" id="InfoId" name="InfoId" class="layui-input" disabled value="@info.InfoId" />
                    </td>
                </tr>
                <tr>
                    <th>我的网名</th>
                    <td>
                        <input type="text" id="InfoName" name="InfoName" class="layui-input" value="@info.InfoName" />
                    </td>
                </tr>
                <tr>
                    <th>我的座右铭</th>
                    <td>
                        <input type="text" id="Motto" name="Motto" class="layui-input" value="@info.Motto" />
                    </td>
                </tr>
                <tr>
                    <th>我的邮箱</th>
                    <td>
                        <input type="text" id="Email" name="Email" class="layui-input" value="@info.Email" />
                    </td>
                </tr>
                <tr>
                    <th>我的QQ群</th>
                    <td>
                        <input type="text" id="Qqgroup" name="Qqgroup" class="layui-input" value="@info.Qqgroup" />
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <input type="button" id="btnEdit" name="btnEdit" value="编辑" onclick="Edit(this)" class="layui-btn layui-btn-radius layui-btn-normal" />
    <input type="button" id="btnSave" name="btnSave" style="display:none" value="保存" onclick="Save(this,@info.InfoId)" class="layui-btn layui-btn-radius" />
</div>

@section Scripts{
    <script>
        function Edit(obj){
            var that = $(obj);
            var read = $('#read');
            var edit = $('#edit');
            that.next().show();
            edit.show();
            read.hide();
            that.hide();
        };
        function Save(obj,InfoId) {
            var that = $(obj);
            var read = $('#read');
            var edit = $('#edit');
            var InfoName = $('#InfoName').val();
            var Motto = $('#Motto').val();
            var Email = $('#Email').val();
            var Qqgroup = $('#Qqgroup').val();
            $.ajax({
                type: 'post',
                url: '../Personal/EditInfo?id=' + InfoId + '&InfoName=' + InfoName + '&Motto=' + Motto + '&Email=' + Email + '&Qqgroup=' + Qqgroup,
                success: function () {
                    layer.msg("修改成功", { icon: 1 });
                    setTimeout(function () {
                        window.location.reload();
                    }, 2000);
                },
                error: function () {
                    layer.msg("修改失败", { icon: 2 });
                }
            });
            //that.prev().show();
            //read.show();
            //edit.hide();
            //that.hide();
        };
    </script>
}
